package myjava.swing;

import javax.swing.*;
import java.awt.*;

/**
 * @author Yancy
 * @program springioctest
 * @create 2020-11-11
 */
public class FlowLayoutDemo {
    private JFrame frame;
    private JButton button1,button2,button3;

  public static void main(String[] args) {
    //
      FlowLayoutDemo flowLayoutDemo = new FlowLayoutDemo();
      flowLayoutDemo.go();
  }
  public void go(){
      frame = new JFrame("Flow Layout");
      //内容窗格
      Container container = frame.getContentPane();
      //设置布局管理器
      container.setLayout(new FlowLayout());
      button1 = new JButton("OK");
      button2 = new JButton("Open");
      button3 = new JButton("Close");
      //向内容窗格添加3个按钮
      container.add(button1);
      container.add(button2);
      container.add(button3);
      //设定窗口大小
      frame.setSize(200,100);
      //显示窗口
      frame.setVisible(true);
      //退出时关闭窗口
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}
